import { Injectable } from '@angular/core';
import { CommHttpService } from '../../../core/comm.http.service';
import { HttpService } from '../../../core/http.service';
import { SERVERS_NAME } from '../../../config/config';

@Injectable()
export class StudentService extends CommHttpService {
  protected preUrl = `${SERVERS_NAME.SECURITY_SERVER}sys/student/`;

  constructor(protected http: HttpService) {
    super(http);
  }

  /**
   * 删除
   */
  delete(arr) {
    return this.http.post(arr, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/student/delete');
  }

  /**
   * 查询部门列表
   */
  getCollege() {
    return this.http.get({}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/dept/list');
  }

  /**
   * 重置密码
   * @ param data da
   */
  resetPassword(ids) {
    return this.http.post({id: ids}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/user/resetPassword');
  }

  /**
   * 查询专业列表
   */
  getMajor(id) {
    return this.http.post([id], `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/college/listMajor');
  }

  /**
   * 查询班级列表
   */
  getClass(id) {
    return this.http.post([id], `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/classes/list');
  }

  /**
   * 导出Excel
   *
   * @param data data
   * @returns {Observable<any>} 返回值
   */
  exportExcel(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/student/exportExcel');
  }

  /**
   * 导入Excel
   *
   * @param fileId Excel文件id
   * @returns {Observable<any>} 返回值
   */
  importExcel(data) {
    return this.http.postFile(data, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/student/importExcel');
  }

  /**
   * 删除附件
   * @param data ['id']
   */
  delFile(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/source/delete');
  }

  /**
   * 获取校区字典和学生类型字典
   */
  getDicList(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/dictionary/page`);
  }
}
